#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e8 + 5;

int n, q;
bool vis[N];
int primes[N], cnt;

void init_primes(int n) {
  vis[1] = 1;
  for (ll i = 2; i <= n; i++) {
    if (!vis[i]) {
      primes[++cnt] = i;
      for (ll j = i * i; j <= n; j += i) vis[j] = 1;
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> q;
  init_primes(n);
  rep(i, 1, q) {
    int k;
    cin >> k;
    cout << primes[k] << endl;
  }
  return 0;
}